14. Install SQLite

Install SQLite

For this lesson, we'll be working with SQLite outside of an Android device. To do that, we'll use something called the terminal. Usually when we interact with a program on our computer, we do so by clicking icons and menu options. Terminals are a way to communicate with your computer that doesn’t involve a Graphical User Interface. Instead, everything you want to do is through text, including navigating around your computer’s file system. If you continue studying Android and programming, you’ll learn a lot more about how to interact with your computer using a terminal. But this is a course about databases, so for now, we’re just going to create a database on our desktop.

Installation

Let's walk through the steps to install SQLite on your computer. Skip to the section below that matches your operating system.

Windows

To install SQLite on a Windows machine, you'll need to

  1. Download the correct Zip files.
  2. Create a folder called C:\sqlite to extract them into.
  3. Add C:\sqlite to your PATH environment variable.
  4. Run the sqlite3 command on your command prompt.

Let's go a bit more in depth on those steps.

To download the correct files, you'll want to go here and download sqlite-tools-win32-*.zip

Once you've downloaded this zip, open up Windows explorer and navigate to your C:\ drive. Once there, create a folder called sqlite. Copy the .zip file you just downloaded into this folder and then extract its contents.

Once you've done that, you'll need to add C:\sqlite to your system's PATH environment variable. If you've never done this before, follow these steps to do so.

Finally, you'll need to open your command prompt program and type in sqlite3, then hit enter.

Here's a video walking through steps above for the Window's installation.

Mac OS X

The most recent version of OS X comes with SQLite pre-installed, so you may not need to do anything here. To check whether that's the case, open your terminal program (which you can find by searching from the magnifying glass in the top-right corner of your desktop) and typing in sqlite3. Then hit enter. If you get a response that includes "SQLite version" and then some numbers, you're in luck!

If not, you'll just need to install it yourself. To do so, you'll download a file, then enter a few commands in your terminal program.

You'll start by going here and downloading sqlite-tools-osx-*.zip

Then you'll need to open your terminal and enter the following commands. Note that the "$" symbol just means the beginning of the line, and you don't need to type that. For the last line, for instance you would just type "make install" and hit enter.

  $tar xvfz sqlite-autoconf-3071502.tar.gz
  $cd sqlite-autoconf-3071502
  $./configure --prefix=/usr/local
  $make
  $make install

With those commands entered, you should now have SQLite installed on your Mac!